// pages/orderinfo/orderinfo.js
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    url: {
      "seleteOrder": app.data.ull + "wxSelectOrder",
    },
    orderId: "",
    orderinfo: ({}),
    showOrHide: 'block',
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    wx.showNavigationBarLoading();
    console.log(options.orderId);
    var that = this;
    that.setData({
      phoneNumber: app.globalData.phone,
      orderId: options.orderId,
    })
    console.log("sadsadsa", that.data.orderId);
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var that = this;
    wx.request({
      url: that.data.url.seleteOrder,
      data: {
        orderId: that.data.orderId,
      },
      header: {
        "Content-Type": "applciation/json"
      },
      method: "GET",
      success: function (res) {
        if (res.data != null) {
          if (res.data.fettlerId == -1) {
            res.data.fettlerId = "未接单"
            that.data.showOrHide = "none";
          } else {
            that.data.showOrHide = "block";
          }
          if (res.data.completedtime == null) {
            res.data.completedtime = "未完成"
          } else {

          }
          that.setData({//如果在sucess直接写this就变成了wx.request()的this了.必须为getdata函数的this,不然无法重置调用函数
            orderinfo: res.data,
            showOrHide: that.data.showOrHide,
          })
          console.log("orderindfo", that.data.orderinfo);
        }
      },
      fail: function (res) { },
      complete: function (res) {
      },
    })

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})